package com.yjm.tb.widget;

import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

import com.yjm.tb.R;
import com.yjm.tb.model.TbTopic;
import com.yjm.tb.view.TbTopicShowActivity;

public class ChoseTypeDlg {

	private AlertDialog dlg = null;

	private Context ctx = null;

	public ChoseTypeDlg(Context ctx) {
		this.ctx = ctx;
	}

	public void showDlg() {
		Button truthBtn = null;
		Button braveBtn = null;

		dlg = new AlertDialog.Builder(ctx).create();
		dlg.show();
		dlg.getWindow().setContentView(R.layout.chose_type_dlg);

		truthBtn = (Button) dlg.getWindow().findViewById(R.id.truth_btn);
		braveBtn = (Button) dlg.getWindow().findViewById(R.id.brave_btn);

		truthBtn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent intent = new Intent(ctx, TbTopicShowActivity.class);
				intent.putExtra("type", TbTopic.TB_TRUTH_TYPE);
				ctx.startActivity(intent);
				dlg.cancel();
			}

		});

		braveBtn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent intent = new Intent(ctx, TbTopicShowActivity.class);
				intent.putExtra("type", TbTopic.TB_BRAVE_TYPE);
				ctx.startActivity(intent);
				dlg.cancel();
			}
		});
	}

}
